using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Xml;

namespace Microsoft.SharedSource.SqlServer.MDDE.ManagementStudio
{
    internal partial class UpgradeTemplateCompleteWizard : UpgradeTemplateBase
    {
        internal UpgradeTemplateCompleteWizard(UpgradeTemplateWizardController controller)
            : base(controller)
        {
            InitializeComponent();
        }

        private void UpgradeTemplateCompleteWizard_VisibleChanged(object sender, EventArgs e)
        {
            // Do nothing if the visibility is false.
            if (this.Visible == false)
                return;

            // Create the Summary text.
            StringBuilder summary = new StringBuilder("Some introduction. \n\n\n");

            summary.Append("\n\nTemplate to be upgraded:\n" + controller.TemplateName);

            summary.Append("\n\nTemplate instances to be upgraded:");

            foreach (XmlNode xInstance in controller.WizardConfigurations.SelectNodes(
                "//Form[@Name=\"SelectedTemplateInstances\"]/UserInput"))
                summary.Append("\n" + xInstance.Attributes["SourceTemplateInstanceName"].Value);

            summary.Append("\n\nPackages to be upgraded:");

            foreach (XmlNode xInstance in controller.WizardConfigurations.SelectNodes(
                "//Form[@Name=\"SelectPackages\"]/UserInput"))
                summary.Append("\n" + xInstance.Attributes["SourcePackageName"].Value);

            // Set the text.
            rtxSummary.Text = summary.ToString();
        }
    }
}